﻿<UserControl x:Class="Aeon.Emulator.Launcher.DiskMounter"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:emu="clr-namespace:Aeon.Emulator;assembly=Aeon.Emulator"
             xmlns:cfg="clr-namespace:Aeon.Configuration;assembly=Aeon.Configuration"
             mc:Ignorable="d" x:Name="root"
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <DataTemplate x:Key="tileView">
            <Grid ToolTip="{Binding Path=DriveConfiguration}">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="60" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="20" />
                    <RowDefinition Height="20"/>
                </Grid.RowDefinitions>
                <Image Name="driveImage" Grid.RowSpan="2" />
                <TextBlock Text="{Binding Path=DriveLetter, StringFormat={}{0}:}" FontSize="13" Margin="0,5,0,1" Grid.Column="1"/>
                <TextBlock Text="{Binding Path=DriveConfiguration, StringFormat={}{0}}" FontSize="12" Margin="0,0,0,1" Padding="0" Grid.Column="1" Grid.Row="1" TextTrimming="CharacterEllipsis" />
            </Grid>
            <DataTemplate.Triggers>
                <DataTrigger Binding="{Binding Path=DriveType}">
                    <DataTrigger.Value>
                        <emu:DriveType>None</emu:DriveType>
                    </DataTrigger.Value>
                    <Setter TargetName="driveImage" Property="Source" Value="Resources/EmptyDrive.png" />
                </DataTrigger>
                <DataTrigger Binding="{Binding Path=DriveType}">
                    <DataTrigger.Value>
                        <emu:DriveType>Floppy35</emu:DriveType>
                    </DataTrigger.Value>
                    <Setter TargetName="driveImage" Property="Source" Value="Resources/3.5_Disk_Drive.png" />
                </DataTrigger>
                <DataTrigger Binding="{Binding Path=DriveType}">
                    <DataTrigger.Value>
                        <emu:DriveType>Floppy525</emu:DriveType>
                    </DataTrigger.Value>
                    <Setter TargetName="driveImage" Property="Source" Value="Resources/525_DiskDrive.png" />
                </DataTrigger>
                <DataTrigger Binding="{Binding Path=DriveType}">
                    <DataTrigger.Value>
                        <emu:DriveType>Fixed</emu:DriveType>
                    </DataTrigger.Value>
                    <Setter TargetName="driveImage" Property="Source" Value="Resources/Hard_Drive.png" />
                </DataTrigger>
                <DataTrigger Binding="{Binding Path=DriveType}">
                    <DataTrigger.Value>
                        <emu:DriveType>CDROM</emu:DriveType>
                    </DataTrigger.Value>
                    <Setter TargetName="driveImage" Property="Source" Value="Resources/CD_Drive.png" />
                </DataTrigger>
            </DataTemplate.Triggers>
        </DataTemplate>
    </UserControl.Resources>
    <UserControl.CommandBindings>
        <CommandBinding Command="New" CanExecute="NewCommandBinding_CanExecute" Executed="NewCommandBinding_Executed" />
        <CommandBinding Command="Delete" CanExecute="DeleteCommandBinding_CanExecute" Executed="DeleteCommandBinding_Executed" />
        <CommandBinding x:Name="propertiesCommand" Command="Properties" CanExecute="PropertiesCommandBinding_CanExecute" Executed="PropertiesCommandBinding_Executed" />
    </UserControl.CommandBindings>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="25" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <StackPanel Grid.Row="0" Orientation="Horizontal">
            <Button Margin="0,0,0,0" Command="New">
                <StackPanel Orientation="Horizontal">
                    <Image Source="Resources/077_AddFile_24x24_72.png" Margin="4,2" />
                    <TextBlock Text="Add..." Margin="0,0,4,0" />
                </StackPanel>
            </Button>
            <Button Margin="4,0,0,0" Command="Properties">
                <StackPanel Orientation="Horizontal">
                    <Image Source="Resources/126_Edit_16x16_72.png" Margin="4,2" />
                    <TextBlock Text="Edit..." Margin="0,0,4,0" />
                </StackPanel>
            </Button>
            <Button Margin="4,0,0,0" Command="Delete">
                <StackPanel Orientation="Horizontal">
                    <Image Source="Resources/delete_12x12.png" Margin="4,2" />
                    <TextBlock Text="Remove" Margin="0,0,4,0" />
                </StackPanel>
            </Button>
        </StackPanel>
        <ListView Name="driveList" ItemTemplate="{StaticResource tileView}" ItemsSource="{Binding ItemsSource, ElementName=root}" Grid.Row="1" MouseDoubleClick="DriveList_MouseDoubleClick" KeyDown="DriveList_KeyDown">
            <ListView.ContextMenu>
                <ContextMenu>
                    <MenuItem Header="Add..." Command="New" />
                    <MenuItem Header="Edit..." Command="Properties" />
                    <MenuItem Header="Remove" Command="Delete" />
                </ContextMenu>
            </ListView.ContextMenu>
        </ListView>
    </Grid>
</UserControl>
